package com.ylsk.mobilecheck.controller;

import com.google.common.collect.Maps;
import com.ylsk.common.annotation.Anonymous;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.system.domain.SysApkPackage;
import com.ylsk.system.mapper.SysApkPackageMapper;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@Api(tags = "app相关接口")
@RestController
@RequestMapping("/mobile")
public class MobileController {

    @Autowired
    private SysApkPackageMapper sysApkPackageMapper;

    /**
     * 获取app最新版本信息
     * @return
     */
    @Anonymous
    @GetMapping("/getAppLastVersion")
    public AjaxResult getAppLastVersion()
    {
        SysApkPackage apkPackgeLastVersion = sysApkPackageMapper.getApkPackgeLastVersion();
        String version = apkPackgeLastVersion.getVersionCode();
        String updateAddress = "http://43.136.130.164:8082/system/file/apk-download";
        Map<String,Object> map = Maps.newHashMap();
        map.put("version",version);
        map.put("updateAddress",updateAddress);
        return AjaxResult.success(map);
    }
}
